﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using MINERP.InfoConfig.Version;

namespace MINERP.InfoConfig
{
    public partial class FrmUpdate : Form
    {
        public FrmUpdate()
        {
            InitializeComponent();
        }

        private void groupBox1_Enter(object sender, EventArgs e)
        {

        }

        private void btnOK_Click(object sender, EventArgs e)
        {
            VersionManager ver = new VersionManager();
            if (string.IsNullOrEmpty(txtVersion.Text.Trim()))
            {
                MessageBox.Show("请输入版本号!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            if (string.IsNullOrEmpty(txtUpdateFilePath.Text.Trim()))
            {
                MessageBox.Show("请选择最新安装包存放路径!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            ver.IniDB(txtVersion.Text.Trim(), txtUpdateFilePath.Text);
            MessageBox.Show("设置成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }

        private void btnICCPath_Click(object sender, EventArgs e)
        {
            if (DialogResult.OK == openFileDialog1.ShowDialog())
            {

                if (openFileDialog1.FileName.Trim().Substring(0, 2) == @"\\")
                {
                    txtUpdateFilePath.Text = openFileDialog1.FileName;
                }
                else
                {
                    MessageBox.Show("请从网上邻居中选择网络路径!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    txtUpdateFilePath.Text = "";
                }
            }
        }

        private void FrmUpdate_Load(object sender, EventArgs e)
        {
            //取出版本并显示
            string version,exePath;
            VersionManager ver = new VersionManager();
            ver.GetVersionNum(out version, out exePath);
            txtVersion.Text = version;
            txtUpdateFilePath.Text = exePath;
        }
    }
}
